function ProductCtrl($scope)
{
    $scope.prods = {};
    $scope.enable = -1;
    var SWITCH_METHOD = 'http://phpsite1:81/php/test.php';




    var getAllProds = function () {
        $.post(SWITCH_METHOD,{method : 'getprods'}, function (response) {
            $scope.prods = JSON.parse(response);
            $scope.$apply();
        });
    };
    $scope.CurrentProd = {};
    var getCurrentProd = function (prod) {
        $.post(SWITCH_METHOD,{data : 'getcurrentprod', data : prod}, function (response) {
            $scope.CurrentProd = JSON.parse(response);
            $scope.$apply();
        });
    };

    $scope.Messages = {};
    var allMessages = function()
    {
        $.post(SWITCH_METHOD,{method : 'GetMessages'}, function (response) {
            $scope.Messages = JSON.parse(response);
            $scope.$apply();
        });
    };

    $scope.edit = function (index) {
    $scope.enable = index;
    };

    $scope.save = function (index) {
        $scope.enable = -1;
        var product = $scope.prods[index];
        $.post(SWITCH_METHOD,{method : 'update', data : product }, function (response) {
        });
    };

    allMessages();
    getCurrentProd();
    getAllProds();

}
